
<!--
/**************************************************
* @ busordercancelsubmit.jsp
*
* Copyright   2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/03/18,owen
*  1) first release
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="../../../common.jsp" %>


<html>
<head>
<title>订单明细内容</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<%

//	ResultProcess tGSProvider = (ResultProcess)request.getAttribute("ordermanufacture");
	ArrayList tList = (ArrayList)request.getAttribute("ordermanufacture");
	ArrayList tRefundList = (ArrayList)request.getAttribute("orderrefunddetail");
	String[] tStr = (String[])request.getAttribute("curorderdetail");
	GSOrderBean tBean = (GSOrderBean)request.getAttribute("orderbean");
	
	//退货状态
	//是否可以操作退货
	boolean isOpRefund = true;
	//可退货的数量
	double canRefundCount = 0;
%>
<%
	if(message == null){
	
%>
<script language="JavaScript">
	var counter;
	function process(val)
	{
		if(val == 'F')
		{
			  var isCanRefund = document.orderdetail.isCanRefund.value;
			  if (isCanRefund == null || isCanRefund=="" || isCanRefund != 1)
			  {
			  	  alert("退货不能操作，请核实该单是否存在状态为：'退货申请'的退货明细！");
			  	  return false;	
			  }
			  
			  var canRefundCount = document.orderdetail.canRefundCount.value;
			  if (canRefundCount == null || canRefundCount == "" || parseFloat(canRefundCount)<=0)
			  {
			  	  canRefundCount = 0;
			  }
			  
			  var refundcount = document.orderdetail.refundcount.value;
			  if (refundcount == null || refundcount.length == 0 || isNaN(refundcount) || parseFloat(refundcount)<=0)
			  {
			  	  alert("退货数量必须是正确的数字！");
			  	  return false;
			  }
			  
			  if (parseFloat(refundcount)>parseFloat(canRefundCount))
			  {
			  	  alert("退货数量不能大于可退货数量："+canRefundCount);
			  	  return false;
			  }
			  
			  if(document.orderdetail.contents.value==null||document.orderdetail.contents.value=="")
			  {
			      alert('必须填写退货原因！');
			      return false;
			  }
			  
			  if(!confirm("确定要退货吗？"))
			  {
			  	return false;
			  }
			  
			  //orderdetail.action = "<%= response.encodeURL(request.getContextPath() + "/A155004.do") %>";
			  //orderdetail.submit();
			  //window.opener.location.reload();
	          var ary = new Array(6);
	          ary[0] = orderdetail.contents.value;
	          ary[1] = orderdetail.orderid.value;
	          ary[2] = orderdetail.status.value;
	          ary[3] = orderdetail.isTradeFlatManuf.value;
	          ary[4] = orderdetail.isTradeFlatProvider.value;
	          ary[5] = orderdetail.refundcount.value;
			  window.returnValue = ary;
			  window.close();			
		}
		else if(val == 'P')
		{
			  if(confirm("是否确定打印？"))
			  {
				  print_bill();//ordermanufacturevdetail.action = "<%=response.encodeURL(root+"/A100305.do")%>";			
			  }
			  else
			  {
				  return false;
			  }
		}
		//ordermanufacturevdetail.submit();
	}

	function keydown2(id)
	{
		if(event.keyCode==13) 
		{
			var obj = document.getElementById(id);
			if (obj.type =="radio")
			{
				obj.checked = true;
			}			
			obj.focus();
		}
	}

</script>
</head>
<body BGCOLOR="#f2f2f2"	text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="orderdetail" method="post">
<p><br></p>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td height="20">
			<table width="100%" border="0" cellspacing="0" cellpadding="1">
				<tr height="20">
					<td height="30" width="758" class="mtxt_black">订单明细内容</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td class="bg_line" height="2"></td>
	</tr>
</table>
<br>
	<center>
    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
    <td>
	    <table class=bg_table id=tableId	cellspacing=1 cellpadding=0 width=100% align=center border=0>
		    <tbody>
			<tr class="bg_row_odd" height="20">
				<td class="top" align="center" width='20%' id='aaa'><div align="center" class="txt_content">订单编号</div></td>
				<td  colspan=5 class="top" width="30%"><div class="txt_content"><%=tBean.getGs_order_tempid()%></div></td>
			</tr>
			<tr class="bg_row_odd" height="20">
				<td class="top" width="13%" align="center">订货单位</td>
				<td class="top" width="20%"><div class="txt_content" align="left"><%=GSBaseManager.getOrderDeptName(tBean.getGs_workcorp_id())%></div></td>
				<td class="top" width="13%" align="center">配送方式</td>
				<td class="top" width="20%"><div class="txt_content" align="left"><%=tBean.getGs_deliver_mode()==null? "":GSBaseManager.getDeliverModeName(tBean.getGs_deliver_mode())%></div></td>
				<td class="top" width="13%" align="center">结算方式</td>
				<td class="top"><div class="txt_content" align="left"><%=tBean.getGs_balance_mode() == null? "":GSBaseManager.getBalanceModeName(tBean.getGs_balance_mode())%></div></td>
			</tr>
			<tr class="bg_row_odd" height="20">
				<td class="top" width="13%" align="center">送货地址</td>
				<td class="top"><div class="txt_content" align="left"><%=tBean.getGs_deliver_goods_addr()%></div></td>	
				<td class="top" width="13%" align="center">联系人</td>
				<td class="top"><div class="txt_content" align="left"><%=tBean.getGs_order_contact_name()==null?"":tBean.getGs_order_contact_name()%></div></td>	
				<td class="top" width="13%" align="center">联系电话</td>
				<td class="top"><div class="txt_content" align="left"><%=tBean.getGs_order_contact_phone()==null?"":tBean.getGs_order_contact_phone()%></div></td>	
			</tr>
			<tr class="bg_row_odd" height="50">
				<td class="top" width="13%" align="center">备注</td>
				<td class="top" colspan=5><div class="txt_content" align="left"><%=tBean.getGs_notes()%></div></td>	
			</tr>
			<tr class=bg_row_odd >
				<td class="top" width="13%" align="center">创建人</td>
				<td class="top"><div class="txt_content"><%=tBean.getGs_recorder_id()%></div></td>	
				<td class="top" width="13%" align="center">创建时间</td>
				<td class="top" colspan=3><div class="txt_content"><%=tBean.getGs_order_create_date()%></div></td>	
			</tr>
			</tbody>
		</table>
		<br>
	<%
		if(tStr != null)
		{
	%>
	    	<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
	            <tbody> 
	            <tr class="bg_column"><td colspan="14"><div align="left" class="txt_content"><b>当前所选订单明细信息</b></div></td></tr>
	            <tr class="bg_column" height=20> 
	                <td class=top align=middle><div align="center" class="txt_content">订单明细编号</div></td>
					<td class=top align=middle><div align="center" class="txt_content">订单明细状态</div></td>	                    
	                <td class=top align=middle><div align="center" class="txt_content">集中编码</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">产品名称</div></td>
					<td class=top align=middle><div align="center" class="txt_content">是否网上产品</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">规格</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">型号</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">品牌</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">供应商</div></td>						
	                <td class=top align=middle><div align="center" class="txt_content">订货数量</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">单价（元）</div></td>						
	                <td class=top align=middle><div align="center" class="txt_content">总价（元）</div></td>						
	                <td class=top align=middle><div align="center" class="txt_content">送货日期</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">送货时间</div></td>                        																																																																	
				</tr>
				<tr height=20 class="bg_row_odd">
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[0]%>&nbsp;
						<input type=hidden name="orderid" value="<%=tStr[0]%>">
						</div>
					</td>
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[13]%>&nbsp;
						<input type=hidden name="status" value="<%=tStr[17]%>">
						</div>
					</td>	
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[1]%>&nbsp;
						</div>
					</td>								
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<a href="<%=response.encodeURL(root+"/A150103.do")%>?&concentricityId=<%=tStr[1]%>" target="contentForm"><%=tStr[2]%></a>
						</div>
					</td>
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=GSBaseManager.getTradeflatName(tStr[15])%>&nbsp;
						</div>
					</td>
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[3]%>&nbsp;
						</div>
					</td>	
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[4]%>&nbsp;
						</div>
					</td>						
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[5]%>&nbsp;
						</div>
					</td>								
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<input type="hidden" name="isTradeFlatManuf" value="<%=tStr[15]%>">
						<input type="hidden" name="isTradeFlatProvider" value="<%=tStr[16]%>">									
						<%
							String temp = "";
							if(tStr[15].equals("0") && tStr[16].equals("0")){
							    temp = "(采购网配送)";
							}
						%>
						<a href="<%=response.encodeURL(root + "/A400108.do?providerId="+tStr[14])%>" target="contentForm"><%=tStr[6]%></a><%=temp%>
						</div>
					</td>	
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[7]%><%=tStr[8]%>&nbsp;
						</div>
					</td>	
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[9]%>元
						</div>
					</td>	
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[10]%>元
						</div>
					</td>	
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[11]%>&nbsp;
						</div>
					</td>																									
					<td class=top align=middle> 
						<div align="center" class="txt_content">
						<%=tStr[12]%>&nbsp;
						</div>
					</td>																
															
				</tr> 				
				</tbody>
			</table>	
			<br>	
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0> 
	            <tr class="bg_column"><td colspan="14" class=top><div align="left" class="txt_content"><b>相关退货单明细信息</b></div></td></tr>
	            <tr class="bg_column" height=20> 
	                <td class=top align=middle><div align="center" class="txt_content">订单明细编号</div></td>
					<td class=top align=middle><div align="center" class="txt_content">订单明细状态</div></td>	                    
	                <td class=top align=middle><div align="center" class="txt_content">集中编码</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">产品名称</div></td>
					<td class=top align=middle><div align="center" class="txt_content">是否网上产品</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">规格</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">型号</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">品牌</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">供应商</div></td>						
	                <td class=top align=middle><div align="center" class="txt_content">退货数量</div></td>
	                <!--
	                <td class=top align=middle><div align="center" class="txt_content">单价（元）</div></td>						
	                <td class=top align=middle><div align="center" class="txt_content">总价（元）</div></td>						
	                -->
	                <td class=top align=middle><div align="center" class="txt_content">申请退货时间</div></td>
	                <td class=top align=middle><div align="center" class="txt_content">退货处理时间</div></td>  	                																																																																	
				</tr>
				<%
					isOpRefund = true;
					canRefundCount = StringUtils.parseDouble(tStr[7]);
					
					if (tRefundList != null && tRefundList.size() > 0)
					{			
						for(int i=0; i<tRefundList.size(); i++)
						{
							String[] tStrRefund = (String[])tRefundList.get(i);
				%>
							<tr height=20 class="bg_row_odd">
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<a href="<%=response.encodeURL(root + "/A150505.do?orderId="+tStrRefund[29]+"&orderDetailId="+tStrRefund[0])%> target="_blank"><%=tStrRefund[0]%></a>&nbsp;
									<input type=hidden name="refundOrderid" value="<%=tStrRefund[0]%>">
									</div>
								</td>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[13]%>&nbsp;
									<input type=hidden name="refundStatus" value="<%=tStrRefund[17]%>">
									<%
										if (tStrRefund[17].equals("51") && isOpRefund != false)
										{
											isOpRefund = false;
										}
										if (!tStrRefund[17].equals("52")) 
										{
											canRefundCount -= StringUtils.parseDouble(tStrRefund[7]);
										}
									%>
									</div>
								</td>	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[1]%>&nbsp;
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<a href="<%=response.encodeURL(root+"/A150103.do")%>?&concentricityId=<%=tStrRefund[1]%>" target="contentForm"><%=tStrRefund[2]%></a>
									</div>
								</td>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=GSBaseManager.getTradeflatName(tStrRefund[15])%>&nbsp;
									</div>
								</td>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[3]%>&nbsp;
									</div>
								</td>	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[4]%>&nbsp;
									</div>
								</td>						
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[5]%>&nbsp;
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<input type="hidden" name="refundIsTradeFlatManuf" value="<%=tStrRefund[15]%>">
									<input type="hidden" name="refundIsTradeFlatProvider" value="<%=tStrRefund[16]%>">									
									<%
										String tempRefund = "";
										if(tStrRefund[15].equals("0") && tStrRefund[16].equals("0")){
										    temp = "(采购网配送)";
										}
									%>
									<a href="<%=response.encodeURL(root + "/A400108.do?providerId="+tStrRefund[14])%>" target="contentForm"><%=tStrRefund[6]%></a><%=tempRefund%>
									</div>
								</td>	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[7]%><%=tStrRefund[8]%>&nbsp;
									</div>
								</td>	
								<!--
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[9]%>元
									</div>
								</td>	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[10]%>元
									</div>
								</td>
								-->	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[11]%>&nbsp;
									</div>
								</td>																									
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStrRefund[22]%>&nbsp;
									</div>
								</td>																
																		
							</tr>				
				<%
						}
				    }
				%>
				</table>
			<br>							
	<%
		}
	%>
			</td>
		</tr>
	</table>
	<br>
		
	<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td class="txt_content" align="center" width="15%">退货数量：<font color="red">（必填）</font></td>
			<td class="txt_content" align="left" width="85%"><input type=text style="WIDTH: 20%" id="refundcount" name="refundcount" onKeyDown="keydown2('contents')">&nbsp;&nbsp;<font color="red"><%=isOpRefund != true ? "当前不能退货！" : "当前可退货数量：" + (canRefundCount <=0 ? "0.00" : StringUtils.formatEDouble(canRefundCount,2))%></font></td>
		</tr>		
		<tr height="30">
			<td class="txt_content" align="center" width="15%">退货原因：<font color="red">（必填）</font></td>
			<td class="txt_content" align="left" width="85%"><TEXTAREA style="WIDTH: 98%" id="contents" name="contents" rows="10"></TEXTAREA></td>
		</tr>
		<tr height="30">
			<td align="center" colspan="2">
				<input type=hidden name="isCanRefund" value="<%=isOpRefund == true ? "1" : "0"%>">
				<input type=hidden name="canRefundCount" value="<%=canRefundCount<0 ? 0 : canRefundCount%>">
				<INPUT type="button" class="kuang" value="确定" onclick="process('F');"	ID="Button1" NAME="Button1"> 
				<INPUT type="button" class="kuang" value="关闭" onclick="self.close();" ID="Button2" NAME="Button1">
			</td>
		</tr>
	</table>
	</center>
</form>
   <%
   } 
   %>

</html>